package com.kaijie.mapper.local;

import com.kaijie.entity.CloudExeLog;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author pxh
 * @TODO TODO
 * @Date 2017/7/4
 */
@Repository
public class CloudExeLogMapper {

    @Resource
    @Qualifier("localSqlSessionTemplate")
    private SqlSessionTemplate localSqlSessionTemplate;

    /**
     * 根据表名、数据来源查询上次数据抓取时间
     *
     * @param map
     * @return
     */
    public List<CloudExeLog> findByTableName(Map<String, Object> map) {
        return localSqlSessionTemplate.selectList(this.getClass().getCanonicalName() + ".findByTableName", map);
    }

    public void save(CloudExeLog cloudExeLog) {
        localSqlSessionTemplate.insert(this.getClass().getCanonicalName() + ".save", cloudExeLog);
    }

    /***
     * 更新抓取时间
     * @param cloudExeLog
     */
    public void update(CloudExeLog cloudExeLog) {
        localSqlSessionTemplate.update(this.getClass().getCanonicalName() + ".update", cloudExeLog);
    }

    public List<CloudExeLog> findAll() {
        return localSqlSessionTemplate.selectList(this.getClass().getCanonicalName() + ".findAll");
    }
}
